<?php
namespace Phone\Controller;

class CommonController extends \Think\Controller{
    public function _initialize(){		
		if(!session('name') && !I('get.openid')){
			redirect(C('DOMAIN')."/Api/ApiList/openid");
		}
		if(I('get.openid')){
			session('openid',I('get.openid'));
			$user = M('User')->
			where(array(
				'openid'=>array('like','%'.I('get.openid').'%')))
				->find();
			if($user){
				session('name',$user['name']);
				session('id',$user['id']);
				$this->redirect("Index/search");
			}
		}
	
        session("name") or die(redirect(U("Login/index")));        
    } 
}